home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / CodeFragments.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  8.0 KB  |  283 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CodeFragments.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __CODEFRAGMENTS__
  18. #define __CODEFRAGMENTS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __FILES__
  27. #include <Files.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <OSUtils.h>                                        */
  31. /*        #include <Memory.h>                                        */
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if GENERATINGPOWERPC
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #ifdef __CFM68K__
  42. #pragma lib_export on
  43. #endif
  44.  
  45.  
  46. enum {
  47.     kCFragResourceType            = 'cfrg',
  48.     kCFragResourceID            = 0,
  49.     kCFragLibraryFileType        = 'shlb'
  50. };
  51.  
  52. typedef OSType CFragArchitecture;
  53.  
  54.  
  55. enum {
  56.     kPowerPCCFragArch            = 'pwpc',
  57.     kMotorola68KCFragArch        = 'm68k',
  58.     kAnyCFragArch                = 0x3F3F3F3F
  59. };
  60.  
  61. typedef UInt32 CFragConnectionID;
  62.  
  63. typedef UInt32 CFragClosureID;
  64.  
  65. typedef UInt32 CFragContextID;
  66.  
  67. typedef UInt32 CFragContainerID;
  68.  
  69. typedef UInt32 CFragLoadOptions;
  70.  
  71.  
  72. enum {
  73.     kLoadCFrag                    = 0x01,                            /* Try to use existing copy, load if not found.*/
  74.     kFindCFrag                    = 0x02,                            /* Try find an existing copy, don't load if not found.*/
  75.     kNewCFragCopy                = 0x05,                            /* Load a new copy whether one already exists or not.*/
  76.     kInplaceCFrag                = 0x80                            /* Use data sections directly in the container.*/
  77. };
  78.  
  79. enum {
  80.     kUnresolvedCFragSymbolAddress = 0
  81. };
  82.  
  83. typedef UInt8 CFragSymbolClass;
  84.  
  85.  
  86. enum {
  87.     kCodeCFragSymbol            = 0,
  88.     kDataCFragSymbol            = 1,
  89.     kTVectorCFragSymbol            = 2,
  90.     kTOCCFragSymbol                = 3,
  91.     kGlueCFragSymbol            = 4
  92. };
  93.  
  94. typedef UInt8 CFragUsage;
  95.  
  96.  
  97. enum {
  98.     kImportLibraryCFrag            = 0,                            /* Standard CFM import library.*/
  99.     kApplicationCFrag            = 1,                            /* Macintosh application.*/
  100.     kDropInAdditionCFrag        = 2                                /* Private extension to an application or library.*/
  101. };
  102.  
  103. enum {
  104.     kIsCompleteCFrag            = 0,                            /* A "base" fragment, not an update.*/
  105.     kFirstCFragUpdate            = 1                                /* The first update, others are numbered 2, 3, ...*/
  106. };
  107.  
  108. typedef UInt8 CFragLocatorKind;
  109.  
  110.  
  111. enum {
  112.     kMemoryCFragLocator            = 0,                            /* Container is already addressable.*/
  113.     kDataForkCFragLocator        = 1,                            /* Container is in a file's data fork.*/
  114.     kResourceCFragLocator        = 2                                /* Container is in a file's resource fork.*/
  115. };
  116.  
  117. #define IsFileLocation(where)     \
  118.     (((where) == kDataForkCFragLocator) || ((where) == kResourceCFragLocator))
  119. enum {
  120.     kCFragGoesToEOF                = 0
  121. };
  122.  
  123. struct CFragOldMemoryLocator {
  124.     LogicalAddress                    address;
  125.     UInt32                            length;
  126.     Boolean                            inPlace;
  127.     UInt8                            reserved3a[3];                /* ! Do not use this!*/
  128. };
  129.  
  130. typedef struct CFragOldMemoryLocator CFragOldMemoryLocator;
  131.  
  132. struct CFragHFSDiskFlatLocator {
  133.     FSSpecPtr                        fileSpec;
  134.     UInt32                            offset;
  135.     UInt32                            length;
  136. };
  137. typedef struct CFragHFSDiskFlatLocator CFragHFSDiskFlatLocator;
  138.  
  139. /* ! This must have a file specification at the same offset as a data fork locator!*/
  140. struct CFragHFSSegmentedLocator {
  141.     FSSpecPtr                        fileSpec;
  142.     OSType                            rsrcType;
  143.     SInt16                            rsrcID;
  144.     UInt16                            reserved2a;                    /* ! Do not use this!*/
  145. };
  146.  
  147. typedef struct CFragHFSSegmentedLocator CFragHFSSegmentedLocator;
  148.  
  149. struct CFragHFSLocator {
  150.     SInt32                            where;                        /* Really of type CFragLocatorKind.*/
  151.     union {
  152.         CFragHFSDiskFlatLocator            onDisk;                    /* First so debugger shows this form.*/
  153.         CFragOldMemoryLocator            inMem;
  154.         CFragHFSSegmentedLocator        inSegs;
  155.     } u;
  156. };
  157.  
  158. typedef struct CFragHFSLocator CFragHFSLocator;
  159.  
  160. typedef CFragHFSLocator *CFragHFSLocatorPtr;
  161.  
  162. /* -------------------------------------------------------------------------------------------*/
  163. /* The parameter block passed to fragment initialization functions.  The locator and name*/
  164. /* pointers are valid only for the duration of the initialization routine.  I.e. if you want*/
  165. /* to save the locator or name, save the contents, not the pointers.  Initialization routines*/
  166. /* take one parameter, a pointer to the parameter block, and return a success/failure result.*/
  167. /* ! Note that the initialization function returns an OSErr.  Any result other than noErr will*/
  168. /* ! cause the entire load to be aborted at that point.*/
  169. struct CFragInitBlock {
  170.     CFragContextID                    contextID;
  171.     CFragClosureID                    closureID;
  172.     CFragConnectionID                connectionID;
  173.     CFragHFSLocator                    fragLocator;
  174.     StringPtr                        libName;
  175.     UInt32                            reserved4a;                    /* ! Do not use this!*/
  176.     UInt32                            reserved4b;                    /* ! Do not use this!*/
  177.     UInt32                            reserved4c;                    /* ! Do not use this!*/
  178.     UInt32                            reserved4d;                    /* ! Do not use this!*/
  179. };
  180. typedef struct CFragInitBlock CFragInitBlock;
  181.  
  182. typedef CFragInitBlock *CFragInitBlockPtr;
  183.  
  184. typedef pascal OSErr CFragInitFunction(const CFragInitBlock *theInitBlock);
  185. typedef pascal void CFragTermRoutine(void);
  186. typedef CFragInitFunction *CFragInitFunctionPtr;
  187.  
  188. typedef CFragTermRoutine *CFragTermRoutinePtr;
  189.  
  190. /* §*/
  191. /* ===========================================================================================*/
  192. /* Routines*/
  193. /* ========*/
  194. extern pascal OSErr GetSharedLibrary(ConstStr63Param libName, OSType archType, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  195.  THREEWORDINLINE(0x3F3C, 0x0001, 0xAA5A);
  196. extern pascal OSErr GetDiskFragment(const FSSpec *fileSpec, UInt32 offset, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  197.  THREEWORDINLINE(0x3F3C, 0x0002, 0xAA5A);
  198. extern pascal OSErr GetMemFragment(void *memAddr, UInt32 length, ConstStr63Param fragName, CFragLoadOptions loadFlags, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage)
  199.  THREEWORDINLINE(0x3F3C, 0x0003, 0xAA5A);
  200. extern pascal OSErr CloseConnection(CFragConnectionID *connID)
  201.  THREEWORDINLINE(0x3F3C, 0x0004, 0xAA5A);
  202. extern pascal OSErr FindSymbol(CFragConnectionID connID, ConstStr255Param symName, Ptr *symAddr, CFragSymbolClass *symClass)
  203.  THREEWORDINLINE(0x3F3C, 0x0005, 0xAA5A);
  204. extern pascal OSErr CountSymbols(CFragConnectionID connID, long *symCount)
  205.  THREEWORDINLINE(0x3F3C, 0x0006, 0xAA5A);
  206. extern pascal OSErr GetIndSymbol(CFragConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, CFragSymbolClass *symClass)
  207.  THREEWORDINLINE(0x3F3C, 0x0007, 0xAA5A);
  208. #if OLDROUTINENAMES
  209. typedef CFragConnectionID ConnectionID;
  210.  
  211. typedef CFragLoadOptions LoadFlags;
  212.  
  213. typedef CFragSymbolClass SymClass;
  214.  
  215. typedef CFragOldMemoryLocator MemFragment;
  216.  
  217. typedef CFragHFSDiskFlatLocator DiskFragment;
  218.  
  219. typedef CFragHFSSegmentedLocator SegmentedFragment;
  220.  
  221. typedef CFragHFSLocator FragmentLocator;
  222.  
  223. typedef CFragHFSLocatorPtr FragmentLocatorPtr;
  224.  
  225. typedef CFragInitBlock InitBlock;
  226.  
  227. typedef CFragInitBlockPtr InitBlockPtr;
  228.  
  229. typedef CFragInitFunction ConnectionInitializationRoutine;
  230.  
  231. typedef CFragTermRoutine ConnectionTerminationRoutine;
  232.  
  233.  
  234. enum {
  235.     kPowerPCArch                = kPowerPCCFragArch,
  236.     kMotorola68KArch            = kMotorola68KCFragArch,
  237.     kAnyArchType                = kAnyCFragArch,
  238.     kNoLibName                    = 0,
  239.     kNoConnectionID                = 0,
  240.     kLoadLib                    = kLoadCFrag,
  241.     kFindLib                    = kFindCFrag,
  242.     kLoadNewCopy                = kNewCFragCopy,
  243.     kUseInPlace                    = kInplaceCFrag,
  244.     kCodeSym                    = kCodeCFragSymbol,
  245.     kDataSym                    = kDataCFragSymbol,
  246.     kTVectSym                    = kTVectorCFragSymbol,
  247.     kTOCSym                        = kTOCCFragSymbol,
  248.     kGlueSym                    = kGlueCFragSymbol,
  249.     kInMem                        = kMemoryCFragLocator,
  250.     kOnDiskFlat                    = kDataForkCFragLocator,
  251.     kOnDiskSegmented            = kResourceCFragLocator,
  252.     kIsLib                        = kImportLibraryCFrag,
  253.     kIsApp                        = kApplicationCFrag,
  254.     kIsDropIn                    = kDropInAdditionCFrag,
  255.     kFullLib                    = kIsCompleteCFrag,
  256.     kUpdateLib                    = kFirstCFragUpdate,
  257.     kCFMRsrcType                = kCFragResourceType,
  258.     kCFMRsrcID                    = kCFragResourceID,
  259.     kSHLBFileType                = kCFragLibraryFileType,
  260.     kUnresolvedSymbolAddress    = kUnresolvedCFragSymbolAddress
  261. };
  262.  
  263. enum {
  264.     kPowerPC                    = kPowerPCCFragArch,
  265.     kMotorola68K                = kMotorola68KCFragArch
  266. };
  267.  
  268. #endif
  269.  
  270. #ifdef __CFM68K__
  271. #pragma lib_export off
  272. #endif
  273.  
  274. #if GENERATINGPOWERPC
  275. #pragma options align=reset
  276. #endif
  277.  
  278. #ifdef __cplusplus
  279. }
  280. #endif
  281.  
  282. #endif /* __CODEFRAGMENTS__ */
  283.